//
//  RecommendPageViewController.m
//  lx
//
//  Created by 李响 on 15/6/9.
//  Copyright (c) 2015年 dllo. All rights reserved.
//
#import "RecommendPageViewController.h"
#import "Table.h"
#import "TableViewOneCell.h"
#import "TableViewTwoCell.h"
#import "CollectionViewOneCell.h"
#import "AFNetworking.h"
#import "UIImageView+WebCache.h"
#import "YRSideViewController.h"
#import "MJRefresh.h"
#import "LBView.h"
#import "SpecialPageViewController.h"
#import "DOPNavbarMenu.h"
#import "ClassifyOneViewController.h"
#import "ClassifyTwoViewController.h"
#import "MyRadioViewController.h"

@interface RecommendPageViewController () <UITableViewDataSource, UITableViewDelegate, UITextViewDelegate, DOPNavbarMenuDelegate>
@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSMutableArray *tempArr;

@property (nonatomic, retain) NSMutableArray *sourceArr1;
@property (nonatomic, retain) NSMutableArray *sourceArr2;
@property (nonatomic, retain) NSMutableArray *sourceArr3;
@property (nonatomic, retain) NSMutableArray *sourceArr4;
@property (nonatomic, retain) NSMutableArray *sourceArr5;
@property (nonatomic, retain)NSMutableArray * array1;
@property (nonatomic, retain)NSMutableArray * array2;
@property (nonatomic, retain)NSMutableArray * array4;
@property (nonatomic, retain)NSMutableArray * array5;

@property (nonatomic, retain)NSMutableArray * lastArrayTO;
@property (nonatomic, retain)NSMutableArray * lastArrayNO;
@property (nonatomic, retain)NSMutableArray * lastArrayMO;
@property (nonatomic, retain)NSMutableArray * lastArrayTT;
@property (nonatomic, retain)NSMutableArray * lastArrayNT;
@property (nonatomic, retain)NSMutableArray * lastArrayMT;

@property (nonatomic, retain) NSString * strN;
@property (nonatomic, retain) NSString * strM;
@property (nonatomic, retain) NSString * strT;
@property (nonatomic, retain) NSString * strNS;
@property (nonatomic, retain) NSString * strMS;
@property (nonatomic, retain) NSString * strTS;

@property (nonatomic, assign) CGFloat lastContentOffset;

@property (assign, nonatomic) NSInteger numberOfItemsInRow;
@property (strong, nonatomic) DOPNavbarMenu *menu;
@end
@implementation RecommendPageViewController
- (void)dealloc
{
    [_menu release];
    [_tableView release];
    [_tempArr release];
    [_array2 release];
    [_array3 release];
    [_array4 release];
    [_array5 release];
    [_array1 release];
    
    [_sourceArr1 release];
    [_sourceArr2 release];
    [_sourceArr3 release];
    [_sourceArr4 release];
    [_sourceArr5 release];
    
    [_lastArrayTO release];
    [_lastArrayNO release];
    [_lastArrayMO release];
    [_lastArrayTT release];
    [_lastArrayNT release];
    [_lastArrayMT release];
    
    [_strM release];
    [_strN release];
    [_strT release];
    
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.tempArr = [NSMutableArray array];
        self.sourceArr1 = [NSMutableArray array];
        self.sourceArr2 = [NSMutableArray array];
        self.sourceArr3 = [NSMutableArray array];
        self.sourceArr4 = [NSMutableArray array];
        self.sourceArr5 = [NSMutableArray array];
        
        self.array1 = [NSMutableArray array];
        self.array2 = [NSMutableArray array];
        self.array3 = [NSMutableArray array];
        self.array4 = [NSMutableArray array];
        self.array5 = [NSMutableArray array];
        
        self.lastArrayTO = [NSMutableArray array];
        self.lastArrayNO = [NSMutableArray array];
        self.lastArrayMO = [NSMutableArray array];
        
        self.lastArrayTT = [NSMutableArray array];
        self.lastArrayNT = [NSMutableArray array];
        self.lastArrayMT = [NSMutableArray array];
    }
    return self;
}
- (DOPNavbarMenu *)menu {
    if (_menu == nil) {
//        DOPNavbarMenuItem *item1 = [DOPNavbarMenuItem ItemWithTitle:@"在线电台" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item2 = [DOPNavbarMenuItem ItemWithTitle:@"搞笑" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item3 = [DOPNavbarMenuItem ItemWithTitle:@"情感治愈" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item4 = [DOPNavbarMenuItem ItemWithTitle:@"音乐" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item5 = [DOPNavbarMenuItem ItemWithTitle:@"大牌节目" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item6 = [DOPNavbarMenuItem ItemWithTitle:@"新闻资讯" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item7 = [DOPNavbarMenuItem ItemWithTitle:@"听小说" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item8 = [DOPNavbarMenuItem ItemWithTitle:@"星座风水" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item9 = [DOPNavbarMenuItem ItemWithTitle:@"极客圈" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item10 = [DOPNavbarMenuItem ItemWithTitle:@"吐槽机" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item11 = [DOPNavbarMenuItem ItemWithTitle:@"XXOO" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item12 = [DOPNavbarMenuItem ItemWithTitle:@"脱口秀" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item13 = [DOPNavbarMenuItem ItemWithTitle:@"娱乐撕逼" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item14 = [DOPNavbarMenuItem ItemWithTitle:@"恐怖惊悚" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item15 = [DOPNavbarMenuItem ItemWithTitle:@"体育" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item16 = [DOPNavbarMenuItem ItemWithTitle:@"好有文化" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item17 = [DOPNavbarMenuItem ItemWithTitle:@"时尚生活" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item18 = [DOPNavbarMenuItem ItemWithTitle:@"相声艺曲" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item19 = [DOPNavbarMenuItem ItemWithTitle:@"汽车" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item20 = [DOPNavbarMenuItem ItemWithTitle:@"商业财经" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item21 = [DOPNavbarMenuItem ItemWithTitle:@"亲子" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item22 = [DOPNavbarMenuItem ItemWithTitle:@"成功励志" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item23 = [DOPNavbarMenuItem ItemWithTitle:@"铁血军事" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item24 = [DOPNavbarMenuItem ItemWithTitle:@"还有啥" icon:[UIImage imageNamed:@"Image"]];
        DOPNavbarMenuItem *item25 = [DOPNavbarMenuItem ItemWithTitle:@"" icon:[UIImage imageNamed:@"Image"]];
        
        self.menu = [[DOPNavbarMenu alloc] initWithItems:@[item2,item3,item4,item5,item6,item7,item8,item9,item10,item11,item12,item13,item14,item15,item16,item17,item18,item19,item20,item21,item22,item23,item24,item25] width:self.view.dop_width maximumNumberInRow:_numberOfItemsInRow];
        _menu.backgroundColor = [UIColor whiteColor];
        _menu.separatarColor = [UIColor purpleColor];
        _menu.delegate = self;
        [_menu release];
    }
    return _menu;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:arc4random() % 255 / 255.0 green:arc4random() % 255 / 255.0  blue:arc4random() % 255 / 255.0 alpha:0.7];
    self.view.backgroundColor = [UIColor blackColor];
    
    self.numberOfItemsInRow = 3;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"分类" style:UIBarButtonItemStylePlain target:self action:@selector(openMenu:)];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];

    UIImage *image2 = [UIImage imageNamed:@"liftFind@2x"];
    image2 = [image2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc]initWithImage:image2 style:UIBarButtonItemStylePlain target:self action:@selector(barButtonAction2:)] autorelease];
    
//    labelTwo.font = [UIFont boldSystemFontOfSize:17];//sy大小
//    防止tableView在scrollView上滚动
//    self.tableViewOne.scrollEnabled = NO;
    [self setUpTableView];
    [self analysis];
    self.navigationController.navigationBar.translucent = NO;
}
- (void)barButtonAction2:(UIBarButtonItem *)barButton
{
    YRSideViewController *ZHAIRUI = (YRSideViewController *)self.view.window.rootViewController;
    [ZHAIRUI showLeftViewController:YES];
}
- (void)setUpTableView
{
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//    self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, LBVIEW_WIDTH1, LBVIEW_HEIGHT1 - 22 *kYHeight) style:UITableViewStyleGrouped];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    [self.tableView addHeaderWithTarget:self action:@selector(analysis)];
    [self.tableView headerBeginRefreshing];
    
//    [self.tableView addFooterWithTarget:self action:@selector(loadMoreData)];
//    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
    [_tableView release];
    //注册//重用池
    [self.tableView registerClass:[TableViewOneCell class] forCellReuseIdentifier:@"diyi"];
    [self.tableView registerClass:[TableViewTwoCell class] forCellReuseIdentifier:@"dier"];
}
- (void)analysis
{
    NSString *str = @"http://api.kaolafm.com/api/v3.5/resource/list?ids=16_-17_-18_-14_5-19_-20_-15_5-21_&installid=0000TLD3&udid=eca85b7ac579ac2b4a4f9fec6744f8fd&sessionid=eca85b7ac579ac2b4a4f9fec6744f8fd1433842263948&imsi=460036090834220&operator=3&network=1&timestamp=1433842412&playid=0341feb3d321649db62216f79fcfa2f5&sign=f3e82c19c896a40926481f50f62d2a8c&appid=0&channel=A-baidu&version=3.6.1&devicetype=0&resolution=480*854&";
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    AFHTTPRequestOperationManager *manger = [AFHTTPRequestOperationManager manager];
    manger.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    [manger GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
            NSDictionary *dic = [responseObject objectForKey:@"result"];
            self.tempArr = [dic objectForKey:@"dataList"];
        
        [self.tableView headerEndRefreshing];
        
        //[self.tableView footerEndRefreshing];
        
        [self shuZu1];
        [self shuZu2];
        [self shuZu3];
        [self shuZu4];
        [self shuZu5];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"网络连接错误" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
        [alert show];
    }];
}
- (void)shuZu1
{
    NSMutableArray *arr1 = [[self.tempArr objectAtIndex:4] objectForKey:@"dataList"];
    self.array1 = [NSMutableArray arrayWithArray:arr1];
    self.sourceArr1 = [Table mainArrWithDicArr:_array1];
    
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height * 1 / 4)];
    
    Table *chendan = [self.sourceArr1 firstObject];
    [image sd_setImageWithURL:[NSURL URLWithString:chendan.pic]];
    self.tableView.tableHeaderView = image;
    
    for (NSMutableDictionary *temyDic in arr1) {
        self.strTS =  [temyDic objectForKey:@"pic"];
    }
    for (NSMutableDictionary *tempDic in arr1) {
        self.strNS = [[[[tempDic objectForKey:@"audioList"] firstObject] objectForKey:@"audioInfo"] objectForKey:@"audioName"];
        self.strMS = [[[[tempDic objectForKey:@"audioList"] firstObject] objectForKey:@"audioInfo"] objectForKey:@"mp3PlayUrl"];
    }
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapActionHeader:)];
    [image addGestureRecognizer:tap];
    image.userInteractionEnabled = YES;
    [tap release];
    [image release];
}
- (void)tapActionHeader:(UITapGestureRecognizer *)tap
{
    MyRadioViewController *myRadioVC = [MyRadioViewController shareInstance];
    myRadioVC.rname = _strNS;
    myRadioVC.mp3Url = _strMS;
    myRadioVC.playImage = _strTS;
    [self.navigationController pushViewController:myRadioVC animated:YES];
}
- (void)shuZu2
{
    NSMutableArray *arr2 = [[self.tempArr objectAtIndex:3] objectForKey:@"dataList"];
    self.array2 = [NSMutableArray arrayWithArray:arr2];
//    self.lastArray = [NSMutableArray arrayWithObject:_str2];
    
    for (NSMutableDictionary *temyDic in arr2) {
        self.strT =  [temyDic objectForKey:@"pic"];
        [self.lastArrayTO addObject:self.strT];
    }
    for (NSMutableDictionary *tempDic in arr2) {
        self.strN = [[[[tempDic objectForKey:@"audioList"] firstObject] objectForKey:@"audioInfo"] objectForKey:@"audioName"];
        self.strM = [[[[tempDic objectForKey:@"audioList"] firstObject] objectForKey:@"audioInfo"] objectForKey:@"mp3PlayUrl"];
        [self.lastArrayNO addObject:self.strN];
        [self.lastArrayMO addObject:self.strM];
    }
//    for (NSString * lx in self.lastArray1) {
//        [self.lastArray addObject:lx];
//    }
    self.sourceArr2 = [Table mainArrWithDicArr:self.array2];
    [self.tableView reloadData];
}
- (void)shuZu3
{
    NSMutableArray *arr3 = [[self.tempArr objectAtIndex:5] objectForKey:@"dataList"];
    self.array3 = [NSMutableArray arrayWithArray:arr3];
    self.sourceArr3 = [Table mainArrWithDicArr:self.array3];
    [self.tableView reloadData];
}
- (void)shuZu4
{
    NSMutableArray *arr4 = [[self.tempArr objectAtIndex:6] objectForKey:@"dataList"];
    self.array4 = [NSMutableArray arrayWithArray:arr4];
    
    for (NSMutableDictionary *temyDic in arr4) {
        self.strT =  [temyDic objectForKey:@"pic"];
        [self.lastArrayTT addObject:self.strT];
    }
    for (NSMutableDictionary *tempDic in arr4) {
        self.strN = [[[[tempDic objectForKey:@"audioList"] firstObject] objectForKey:@"audioInfo"] objectForKey:@"audioName"];
        self.strM = [[[[tempDic objectForKey:@"audioList"] firstObject] objectForKey:@"audioInfo"] objectForKey:@"mp3PlayUrl"];
        [self.lastArrayNT addObject:self.strN];
        [self.lastArrayMT addObject:self.strM];
    }
    self.sourceArr4 = [Table mainArrWithDicArr:self.array4];
    [self.tableView reloadData];
}
- (void)shuZu5
{
    NSMutableArray *arr5 = [[self.tempArr objectAtIndex:7] objectForKey:@"dataList"];
    self.array5 = [NSMutableArray arrayWithArray:arr5];
    self.sourceArr5 = [Table mainArrWithDicArr:self.array5];
    [self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        
        TableViewOneCell *cell = [tableView dequeueReusableCellWithIdentifier:@"diyi"];
        Table *main = [self.sourceArr2  objectAtIndex:indexPath.row];
        cell.main = main;
        [cell sendIndex:indexPath.row section:indexPath.section];
        //self.alldetail = [self.sourceArr2 objectAtIndex:indexPath.row];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        [cell.playImageView addGestureRecognizer:tap];
        
        [tap release];
        
        return cell;
    }
    else if (indexPath.section == 1) {
        TableViewTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"dier"];
        //        Table *main = [self.sourceArr3  objectAtIndex:indexPath.row];
        cell.array = self.sourceArr3;
        cell.arrayOfDic = self.array3;
        return cell;
        
    } else if (indexPath.section == 2) {
        
        TableViewOneCell *cell = [tableView dequeueReusableCellWithIdentifier:@"diyi"];
        Table *main = [self.sourceArr4  objectAtIndex:indexPath.row];
        [cell sendIndex:indexPath.row section:indexPath.section];
        //cell.str = @"wwww";
        
        
        //self.alldetail = [self.sourceArr2 objectAtIndex:indexPath.row];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        [cell.playImageView addGestureRecognizer:tap];
        
        [tap release];
        cell.main = main;
        return cell;
    } else if (indexPath.section == 3) {
        TableViewTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"dier"];
        cell.array = self.sourceArr5;
        cell.arrayOfDic = self.array5;
        return cell;
    }
    return 0;
}
- (void)tapAction:(UITapGestureRecognizer *)tap
{
    MyRadioViewController *myRadioVC = [MyRadioViewController shareInstance];
    
    MyImageView *myImageView = (MyImageView *)tap.view;
    if (myImageView.section == 0) {
        NSString *strNO = [self.lastArrayNO objectAtIndex:myImageView.index];
        NSString *strTO = [self.lastArrayTO objectAtIndex:myImageView.index];
        NSString *strMO = [self.lastArrayMO objectAtIndex:myImageView.index];
        myRadioVC.rname = strNO;
        myRadioVC.mp3Url = strMO;
        myRadioVC.playImage = strTO;
    } else if (myImageView.section == 2) {
        NSString *strNT = [self.lastArrayNT objectAtIndex:myImageView.index];
        NSString *strTT = [self.lastArrayTT objectAtIndex:myImageView.index];
        NSString *str9MT = [self.lastArrayMT objectAtIndex:myImageView.index];
        myRadioVC.rname = strNT;
        myRadioVC.mp3Url = str9MT;
        myRadioVC.playImage = strTT;
    }
    //myRadioVC.mp3Url = [NSString stringWithFormat:@"%@", self.str2];
    [self.navigationController pushViewController:myRadioVC animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return self.sourceArr2.count;
    }else if (section == 1){
        return 1;
    } else if (section == 2){
        return self.sourceArr4.count;
    } else if (section == 3){
        return 1;
    }
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        return self.view.bounds.size.height / 7;
        
    } else if(indexPath.section == 1)
    {
        return self.view.bounds.size.height / 2;
        
    } else if(indexPath.section == 2)
    {
        return self.view.bounds.size.height / 7;
        
    } else if(indexPath.section == 3)
    {
        return self.view.bounds.size.height / 2 + self.view.bounds.size.height / 13;
    }
    return 0;
}
//- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
//{
//    if (section == 0) {
//        return @"大牌节目";
//    } else if (section == 1){
//        return @"热门推荐";
//    } else if (section == 2){
//        return @"精品博客";
//    } else if (section == 3){
//        return @"合作专区";
//    }
//        return 0;
//}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    LBView *sectionView = [[LBView alloc] init];
    sectionView.sectionLabel.textColor = [UIColor whiteColor];
    if (section == 0) {
        sectionView.sectionLabel.text = @"--大牌节目--";
        return sectionView;
    } else if (section == 1) {
        sectionView.sectionLabel.text = @"--热门推荐--";
        return sectionView;
    } else if (section == 2) {
        sectionView.sectionLabel.text = @"--精品博客--";
        return sectionView;
    } else if (section == 3) {
        sectionView.sectionLabel.text = @"--合作专区--";
        return sectionView;
    }
    
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30.f * kYHeight;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.1f;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.backgroundColor = [UIColor colorWithRed:0.88 green:0.90 blue:0.738 alpha:0.4];
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    SpecialPageViewController *specialVC = [[SpecialPageViewController alloc] init];
    if (indexPath.section == 0) {
        
        specialVC.rid = [[[self.array2 objectAtIndex:indexPath.item] objectForKey:@"rid"] description];
        
        specialVC.pic = [[self.array2 objectAtIndex:indexPath.item] objectForKey:@"pic"];
        
        specialVC.hostName = [[[[self.array2 objectAtIndex:indexPath.item] objectForKey:@"host"] firstObject] objectForKey:@"name"];
        
        specialVC.foucsNum = [[self.array2 objectAtIndex:indexPath.item] objectForKey:@"followedNum"];
        
        specialVC.listenNum = [[self.array2 objectAtIndex:indexPath.item] objectForKey:@"listenNum"];
        
        specialVC.descRadio = [[self.array2 objectAtIndex:indexPath.item] objectForKey:@"radioDesc"];
        
        specialVC.titleLabel = [[self.array2 objectAtIndex:indexPath.item] objectForKey:@"rname"];
    } else if(indexPath.section == 2) {
        
        specialVC.rid = [[[self.array4 objectAtIndex:indexPath.item] objectForKey:@"rid"] description];
        
        specialVC.pic = [[self.array4 objectAtIndex:indexPath.item] objectForKey:@"pic"];
        
        specialVC.hostName = [[[[self.array4 objectAtIndex:indexPath.item] objectForKey:@"host"] firstObject] objectForKey:@"name"];
        
        specialVC.foucsNum = [[self.array4 objectAtIndex:indexPath.item] objectForKey:@"followedNum"];
        
        specialVC.listenNum = [[self.array4 objectAtIndex:indexPath.item] objectForKey:@"listenNum"];
        
        specialVC.descRadio = [[self.array4 objectAtIndex:indexPath.item] objectForKey:@"radioDesc"];
        
        specialVC.titleLabel = [[self.array4 objectAtIndex:indexPath.item] objectForKey:@"rname"];
    }
    [self.navigationController pushViewController:specialVC animated:YES];
    
    [specialVC release];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if (self.menu) {
        [self.menu dismissWithAnimation:NO];
    }
}

- (void)openMenu:(id)sender {
    self.navigationItem.rightBarButtonItem.enabled = NO;
    if (self.menu.isOpen) {
        [self.menu dismissWithAnimation:YES];
    } else {
        [self.menu showInNavigationController:self.navigationController];
    }
}

- (void)didShowMenu:(DOPNavbarMenu *)menu {
    [self.navigationItem.rightBarButtonItem setTitle:@"返回"];
    self.navigationItem.rightBarButtonItem.enabled = YES;
}

- (void)didDismissMenu:(DOPNavbarMenu *)menu {
    [self.navigationItem.rightBarButtonItem setTitle:@"分类"];
    self.navigationItem.rightBarButtonItem.enabled = YES;
}

- (void)didSelectedMenu:(DOPNavbarMenu *)menu atIndex:(NSInteger)index {

//    if (index == 0) {
//        ClassifyOneViewController *secondVC = [[ClassifyOneViewController alloc] init];
//        [self.navigationController pushViewController:secondVC animated:YES];
//        [secondVC release];
//    } else
        if (index == 0) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"648";
        [secondVC release];
    } else if (index == 1) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"699";
        [secondVC release];
    } else if (index == 2) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"255";
        [secondVC release];
    } else if (index == 3) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"727";
        [secondVC release];
    } else if (index == 4) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"706";
        [secondVC release];
    } else if (index == 5) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"32";
        [secondVC release];
    } else if (index == 6) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"195";
        [secondVC release];
    } else if (index == 7) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"656";
        [secondVC release];
    } else if (index == 8) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"1";
        [secondVC release];
    } else if (index == 9) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"26";
        [secondVC release];
    } else if (index == 10) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"25";
        [secondVC release];
    } else if (index == 11) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"12";
        [secondVC release];
    } else if (index == 12) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"664";
        [secondVC release];
    } else if (index == 13) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"18";
        [secondVC release];
    } else if (index == 14) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"657";
        [secondVC release];
    } else if (index == 15) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"21";
        [secondVC release];
    } else if (index == 16) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"114";
        [secondVC release];
    } else if (index == 17) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"662";
        [secondVC release];
    } else if (index == 18) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"655";
        [secondVC release];
    } else if (index == 19) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"201";
        [secondVC release];
    } else if (index == 20) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"200";
        [secondVC release];
    } else if (index == 21) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"712";
        [secondVC release];
    } else if (index == 22) {
        ClassifyTwoViewController *secondVC = [[ClassifyTwoViewController alloc] init];
        [self.navigationController pushViewController:secondVC animated:YES];
        secondVC.keBian = @"665";
        [secondVC release];
    } else if (index == 23) {
        UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"小编正在开发中" message:[NSString stringWithFormat:@"提示 %@", @"😊"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [av show];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
- (void)textViewDidChange:(UITextView *)textView {
    self.numberOfItemsInRow = [textView.text integerValue];
    self.menu = nil;
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    self.menu = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    
    // 设置navigationController.navigationBar标题颜色
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil]];
    
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.097 green:0.6701 blue:0.4134 alpha:1.0];
}

////上拉隐藏tabBar
//- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
//{
//    self.lastContentOffset = scrollView.contentOffset.y;
//}
//
//- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
//{
//    if (self.lastContentOffset > scrollView.contentOffset.y) {
//        
//        self.tabBarController.tabBar.hidden = NO;
//        
//    } else {
//        
//        self.tabBarController.tabBar.hidden = YES;
//    }
//}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
